<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.lp.cfg.ProConfig"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
<head>
	<title><%=ProConfig.PROJECT_NAME %></title>
	<%@ include file="/WEB-INF/wechat/iot/common/resource_lib.jsp"%>
	<style type="text/css">
		.title-container{
			height: 50px;
			line-height: 48px;
			text-align: center;
			background: #fff;
		}
		
		.title-container .width20{
			font-weight: 540;
		}
		
		.title-container .width33.active{
			border-bottom: 2px solid #46addb;
			color:#46addb;
		}
		
		.weui-panel.weui-panel_access{
			border-radius: 5px;
		}
		.weui-cells{
			color: #333;
		}
		.weui-cells label{
			font-size: 15px;
		}
		.weui-cells span{
			font-size: 14px;
		}
	</style>
</head>
<body>
	<div class="container">
		
		<div class="t-c title-info" onclick="backup()">
			<span>Sensing information</span>
			<div class="back" style=" position: fixed;top: 0px;" >
			Back</div>
		</div>
		<div style="height: 50px;"></div>
		<div class="clear title-container">
			<div class="float-left width33 pointer active" url="/wiot/sensor?id=">
				<span>Basic information</span>
			</div>
			<div class="float-left width33 pointer" url="/wiot/history?id=">
				<span>Data curve</span>
			</div>
			<div class="float-left width33 pointer" url="/wiot/trigger?id=">
				<span>Trigger information</span>
			</div>
		</div>
		
		<div class="jui-detail_get" config-option=" url:'/sensor.json?id=$#sensorId$',success:'successBack' ">
			<input type="hidden" id="sensorId">
			<div class="weui-cells weui-cells_form" >
				<div class="weui-cell">
					<div class="weui-cell__hd">
						<label for="" class="weui-label">Current value</label>
					</div>
					<div class="weui-cell__bd">
						<span style="color: cornflowerblue;" id="sensorvalue"></span>
					</div>
				</div>
				<div class="weui-cell">
					<div class="weui-cell__hd">
						<label for="" class="weui-label">Owning device</label>
					</div>
					<div class="weui-cell__bd">
						<span type-name="node_name" type-value="h"></span>
					</div>
				</div>
				<div class="weui-cell">
					<div class="weui-cell__hd">
						<label for="" class="weui-label">Sensor name</label>
					</div>
					<div class="weui-cell__bd">
						<span type-name="name" type-value="h"></span>
					</div>
				</div>
				<div class="weui-cell">
					<div class="weui-cell__hd">
						<label for="" class="weui-label">type</label>
					</div>
					<div class="weui-cell__bd">
						<span style="color:darkolivegreen;" type-name="iot_sensor_type" type-value="ch"></span>
					</div>
				</div>
			</div>
			
			<div class="weui-cells weui-cells_form" style="margin-top: 0.67647059em;">
				<div class="weui-cell">
					<div class="weui-cell__hd">
						<label for="" class="weui-label">Update time</label>
					</div>
					<div class="weui-cell__bd">
						<span id="register_time"></span>
					</div>
				</div>
			</div>
		</div>
		
	</div>

</body>
	<script type="text/javascript">
	
		function backup(){
			forward('/wiot/device?id='+  GetQueryString("did"));
		}
	
		$(function(){
			$("#sensorId").val( GetQueryString("id") );
			
			$(".title-container .width33").click(function(){
				forward( $(this).attr("url") + GetQueryString("id")  +"&did="+ GetQueryString("did") );
			})
		})
		
		function successBack(data){
			if(isOK(data)){
				$("#sensorvalue").html(data.data.sdata+" "+ data.data.data.measure_unit_type);
				if( data.data.iot_sensor_status == 16 ){
					$("#sensorStatus").css("color","green");
				}else{
					$("#sensorStatus").css("color","red");
				}
				$("#register_time").html( time2Str(data.data.mtime) );
			}
		}
	</script>
</html>